import ScrollBarLayout from '@/components/ScrollBarLayout';
import moment from 'moment';
import Cls from 'classnames';
import { useCallback, useEffect, useMemo, useState } from 'react';
import pageStyles from '@/common/pageLayout.less';
import { DescriptionsType } from '@/components/DescriptionsType';
import { getTenantID, getPosIDs, getUserID } from '@/utils';
import { getUpdateConfig } from '../mconfig/UpdateConfig';
import { connect, history } from 'umi';
import { Col, Form, Row, Spin, message, Tabs, Button, Space, Modal } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
import { OpenMaterialModal } from '../mconfig/OpenMaterialModal';
import { AcquisitionManageContext, ApplyStorageModal } from '../mconfig';
import { useAcquisitionManageReducer, IAcquisitionActionEnum } from '../mconfig';
import {
  addStorageService,
  approvedEnterSerivice,
  editStorageService,
  enrolStorageService,
  getDetailService,
  getStorageTreeService,
  MaterialServices,
} from '../services';
import { ILoadMapTypeAll } from '@/common';
import { WorkflowChedkRecord, WorkflowNoDefaultTable, WorkflowSwitchModal } from '@/components/WorkflowCommonCopy';
import '../common/style.less';
import { orderType, requestController } from '../common/Format';
import { SelectAssetView } from './SelectAssetView';
import { assetTypeList } from './AssetTypeView';
import { UploadModal } from './UploadModal';
import { OneModal } from '@/components/one-ui';
import { DetailInfoViewBottomBtn } from '../mconfig/DetailInfoViewBottomBtn';
import { RevokeModal } from '@/pages/AssetManage/Acomponents/RevokeModal';
import { editMaterialServices } from '../services';
import { ExportModal } from './ExportModal';

const AcceptUpdateView: React.FC<any> = ({ curRes, locationProps }) => {
  // 引入上下文
  const { materielList, selectType, assetTypeInfo, selectApplyStorageList, selectFormInfo, selectAsssetInfo, selectRecordId, acquisitionDispatch } =
    useAcquisitionManageReducer();

  // 样式根目录
  const styleFixCls = 'contract-styfixcls-';

  let [materialToatalPrice, setMaterialToatalPrice] = useState<string>('');

  const [saveFlag, setSaveFlag] = useState<boolean>(false);

  let [pagination, setPagination] = useState<any>({
    current: 1,
    pageSize: 10,
    total: 0,
    // showSizeChanger: false,
  });

  // 表单
  const [contractForm] = Form.useForm();
  // 打开选择物料列表
  const [openMaterialModal, setOpenMaterialModal] = useState<Record<string, any>>({});
  // 选择资产弹窗
  const [selectAssetVisible, setSelectAssetVisible] = useState<boolean>(false);
  // 弹窗类型   查看/修改/新增
  const [formModalType, setFormModalType] = useState<string>('');
  // 打开到货验收list弹窗
  const [selectApplyStorage, setSelectApplyStorage] = useState<boolean>(false);
  // 导入文件弹窗
  const [isShowBatch, setIsShowBatch] = useState<boolean>(false);
  // 导入文件之前获取的表单数据
  const [downLoadData, setDownLoadData] = useState<any>({});
  // 详情数据
  const [detailInfo, setDetailInfo] = useState<any>({});
  // 仓库树数据
  const [storageList, setStorageList] = useState<any>([]);
  // 是否登记确认弹窗
  const [isShowConfirm, setIsShowConfirm] = useState<boolean>(false);
  // 判断是否是当前审批人
  const [isNowCheckPeople, setIsNowCheckPeople] = useState<boolean>(false);
  // 入库登记审批同意判断是否可以调用同步接口
  const [auditSuccessState, setAuditSuccessState] = useState(false);
  // 是否显示撤销弹窗
  const [invalidState, setInvalidState] = useState<Record<string, any>>({}); /**撤销弹窗*/
  // 工作流
  const [isShowWorkRecord, setIsShowWorkRecord] = useState<boolean>(false);
  const [showSwitchFlow, setShowSwitchFlow] = useState<boolean>(false);
  const [workFlowInfoObj, setWorkFlowInfoObj] = useState<Record<string, any>>({
    selectFlowRows: {},
    showWorkFlowModal: false,
    saveNoDefaultFlowID: '',
  });

  // 点击添加  弹窗
  const handleMaterialModal = () => {
    const tempType = contractForm.getFieldValue('materialType').toString();
    if (!tempType) {
      return message.warning('请选择物资类型');
    }
    setOpenMaterialModal({
      isShow: true,
      materialType: tempType,
    });
  };

  // 获取物料列表回调
  const materialCallback = (res: any) => {
    setMaterialToatalPrice(res?.msg || '');
    setPagination({
      ...pagination,
      total: res?.total || 0,
    });
    const dataRow = res?.rows?.map((item) => {
      return {
        ...item,
        supplier: item?.assetjson?.supplier,
      };
    });
    acquisitionDispatch({
      type: IAcquisitionActionEnum.SELECT_MATERIEL,
      payload: dataRow,
    });
  };

  // 管理页services
  const { loading, reloadRequest } = MaterialServices(materialCallback);

  // 修改申请回调
  const editMaterialCallback = useCallback(
    (res: any) => {
      if (res && res?.msgFlag) {
        if (selectType === 0) {
          // onSelectRadio(res?.obj, false);
          reloadManage();
          onSelectRadio_s(res?.obj, false);
        }
        if (selectType === 1) {
          reloadManage();
        }
        message.success(res?.msg);
      } else {
        message.error(res?.msg);
      }
    },
    [selectType],
  );

  // 修改物资
  const { editMaterialRun, editMaterialLoading } = editMaterialServices(editMaterialCallback);

  // 点击修改/查看
  const handleAssetVisible = (formType: string, record: any) => {
    if (contractForm.getFieldValue('materialType') == 1) {
      // 点击数据的id
      const recordId = record.id || record.rowId; // 数据的标识，优先使用id，自行添加的是rowId
      // 表单数据
      const formData = record.assetjson || {};
      // 更新选中当前的id
      acquisitionDispatch({
        type: IAcquisitionActionEnum.SELECT_RECORD_ID,
        payload: recordId,
      });
      // 更新当前的表单数据
      acquisitionDispatch({
        type: IAcquisitionActionEnum.SELECT_FORM_INFO,
        payload: formData,
      });

      setFormModalType(formType);
      setSelectAssetVisible(true);
    } else if ((formType = 'saveMaterial')) {
      editMaterialRun(record);
    }
  };

  // 点击到货验收list 弹窗
  const handleApplyStorage = () => {
    setSelectApplyStorage(true);
  };

  // 点击导入
  const handleBatchModal = () => {
    // 对表单进行校验，获取表单数据
    contractForm.validateFields()?.then((values: any) => {
      values.createTime = moment(values?.createTime).format('YYYY-MM-DD HH:mm:ss');
      setDownLoadData(values);
      setIsShowBatch(true);
    });
  };

  // 处理工作流功能 权限
  const workflowPowerAllBtn = useMemo(() => {
    let pownerBtn: Record<string, any> = {
      revokeFlagBtn: false, //撤销按钮
      invalBoolBtn: false, //暂停开始按钮
      stopProcInstBtn: false, //流程作废接口
    };
    if (detailInfo?.state == `${getTenantID()}${ILoadMapTypeAll?.DISCLOSURE_STATE}1001`) {
      pownerBtn['revokeFlagBtn'] = true;
      pownerBtn['stopProcInstBtn'] = true;
    }

    const taskType: string = `${getTenantID()}${ILoadMapTypeAll.ALLFLOW_TYPE}1001`;
    const taskHandInfo: Record<string, any> = detailInfo?.paramObject?.[taskType];
    if (
      taskHandInfo &&
      taskHandInfo?.mactivitiTaskList?.length > 0 &&
      taskHandInfo?.mactivitiTaskList?.[0]?.assigneePositionID == getPosIDs() &&
      taskHandInfo?.mactivitiTaskList?.[0]?.assigneeID == getUserID()
    ) {
      pownerBtn['invalBoolBtn'] = true;
    }
    return pownerBtn;
  }, [detailInfo]);

  // 切换入库类型
  // const handleChangeType = (type) => {
  //   // 0 材料入库 1资产入库
  //   acquisitionDispatch({
  //     type: IAcquisitionActionEnum.SELECT_TYPE,
  //     payload: type,
  //   });
  //   acquisitionDispatch({
  //     type: IAcquisitionActionEnum.CANCEL_MATERIEL,
  //   });
  // };

  /**
   * 新增编辑回调
   * @param res 接口返回数据
   * @param callType true 为新增回调  || false 为编辑回调
   */
  const updateAnnounceCallback = (res: any) => {
    if (res && res?.msgFlag) {
      // flag 表示点击的提交
      if (saveFlag) {
        setDetailInfo(res?.obj);
        setWorkFlowInfoObj({
          selectFlowRows: res?.obj,
          showWorkFlowModal: true,
          saveNoDefaultFlowID: '',
        });
      } else {
        message.success(res?.msg);
        history.push({
          pathname: '/assetStorage/manage',
          state: {
            delRouterNameSource: history.location.pathname,
          },
        });
      }
    } else {
      message.error(res?.msg);
    }
  };

  const updataEnrolCallback = (res: any) => {
    if (res && res?.msgFlag) {
      message.success(res?.msg);
    } else {
      message.error(res?.msg);
    }
    history.push({
      pathname: '/assetStorage/manage',
      state: {
        delRouterNameSource: history.location.pathname,
      },
    });
  };

  /**
   * 获取详情回调
   * @param res 接口返回数据
   */
  const updataGetDetail = (res: any) => {
    if (res && res?.msgFlag) {
      const {
        obj: { materialType, massetMaterials },
      } = res;
      message.success(res.msg || '获取详情成功');
      // 详情数据
      setDetailInfo(res?.obj);
      // 更新回显选择的类型   材料/资产
      acquisitionDispatch({
        type: IAcquisitionActionEnum.SELECT_TYPE,
        payload: materialType,
      });
      // acquisitionDispatch({
      //   type: IAcquisitionActionEnum.SELECT_MATERIEL,
      //   payload: massetMaterials,
      // });
      // 如果是资产 则回显表单数据
      acquisitionDispatch({
        type: IAcquisitionActionEnum.SELECT_FORM_INFO,
        payload: materielList[0]?.assetjson,
      });
      // 设置回显选择的会计科目
      const tempData = assetTypeList.find((item: any) => item.title == materielList[0]?.assetjson?.ledgerAccount);
      const tempAssetTypeData = {
        assetType: tempData?.title,
        number: tempData?.id,
      };
      acquisitionDispatch({
        type: IAcquisitionActionEnum.SELECT_ASSET_INFO,
        payload: tempAssetTypeData,
      });

      // 判断是否是当前审批人
      let taskList = res?.obj?.paramObject?.['100199031020']?.mactivitiTaskList;
      if (taskList == undefined) setIsNowCheckPeople(true);
      if (res?.obj?.id && taskList) {
        let taskNode = taskList?.find((item) => item?.assigneeID == getUserID() && item?.assigneePositionID == getPosIDs());
        if (taskNode) {
          setIsNowCheckPeople(true);
        }
      }

      /** 是否是审核中 */
      if (
        res?.obj?.checkState === `${getTenantID()}${ILoadMapTypeAll.ALLFLOW_CHECKRESULT}1000` &&
        res?.obj?.state === `${getTenantID()}${ILoadMapTypeAll.ENTER_STORE_STATUS}1001`
      ) {
        setAuditSuccessState(true);
      }
    } else {
      message.error(res.msg || '获取详情失败');
    }
  };

  // 获取仓库树回调
  const updataGetStorage = (res: any) => {
    if (res && res?.msgFlag) {
      setStorageList(res?.obj);
    }
  };

  // 获取仓库树
  // const { getStorageLoading, getStorageRun } = getStorageTreeService(updataGetStorage, curRes);
  // 获取入库详情
  const { getDetailLoading, getDetailRun } = getDetailService(updataGetDetail);
  // 提交入库申请
  const { addStorageLoading, addStorageRun } = addStorageService(updateAnnounceCallback);
  // 编辑入库申请
  const { editStorageLoading, editStorageRun } = editStorageService(updateAnnounceCallback);
  // 提交申请
  // const { enrolStorageLoading, enrolStorageRun } = enrolStorageService(updataEnrolCallback);
  /** 入库登记 -最后一个人审核通过后调用的同步接口 */
  const { approvedEnterRun, approvedEnterLoading } = approvedEnterSerivice((res) => {
    if (res && res?.msgFlag) {
      message.success(res?.msg);
      history.push({
        pathname: '/assetStorage/manage',
        state: {
          delRouterNameSource: history.location.pathname,
        },
      });
    } else {
      message.error(res?.msg);
    }
  });

  // 切换不是新购的操作
  const changeSelect = () => {
    setDetailInfo({
      ...detailInfo,
      applyStorageTitle: '',
    });
    acquisitionDispatch({
      type: IAcquisitionActionEnum.SELECT_APPLY_STORAGE,
      payload: [],
    });
  };

  // 入库类型
  // const changeType = () => {
  //   acquisitionDispatch({
  //     type: IAcquisitionActionEnum.CANCEL_MATERIEL,
  //   });
  //   contractForm?.setFieldsValue({
  //     ...contractForm,
  //     id: '',
  //   });
  // };

  // 刷新管理页面的办法
  const reloadManage = () => {
    reloadRequest({
      storageId: contractForm.getFieldValue('id'),
    });
  };

  // 分页方法
  const onPageChange = (current: any, pageSize: any, params: any) => {
    setPagination({
      ...pagination,
      current,
      pageSize,
    });
    // reloadRequest({ current, pageSize, storageId: contractForm.getFieldValue('id') });
  };

  /** 暂时保存选中的值 */
  const [checkMaterialList, setCheckMaterialList] = useState<Record<string, any>[]>([]);

  /** 点击选中 */
  const onSelectTable = (selectInfo) => {
    setCheckMaterialList(selectInfo);
    acquisitionDispatch({
      type: IAcquisitionActionEnum.SELECT_MATERIEL,
      payload: [...materielList],
    });
  };

  /** 选中 */
  const onSelectRadio = (record: Record<string, any>, selected: boolean) => {
    if (selected) {
      let selectList: Record<string, any>[] = [...checkMaterialList];
      selectList?.push({ ...record });
      onSelectTable(selectList);
    } else {
      let selectList: Record<string, any>[] = checkMaterialList?.filter((item: any) => item?.['id'] != record?.['id']);
      onSelectTable(selectList);
    }
  };

  /** 选中方法2 【checkMaterialList集合是作为表格中表单是否禁用的条件】 */
  const onSelectRadio_s = (record: Record<string, any>, selected: boolean) => {
    if (selected) {
      let selectList: Record<string, any>[] = [...checkMaterialList];
      selectList?.push({ ...record });
      setCheckMaterialList(selectList);
    } else {
      let selectList: Record<string, any>[] = checkMaterialList?.filter((item: any) => item?.['id'] != record?.['id']);
      setCheckMaterialList(selectList);
    }
  };

  // 是否显示导出物资弹窗state
  const [isShowImportModal, setIsShowImportModal] = useState<Record<string, any>>({});

  /** 获取表单配置
   *  @pageType  传递的类型，是修改还是查看
   *  @record   当前项
   */
  const { config } = getUpdateConfig({
    pageType: locationProps?.state?.pageType ? locationProps?.state?.pageType : '',
    record: locationProps?.state?.record ? (detailInfo ? Object.assign({}, locationProps?.state?.record, detailInfo) : locationProps?.state?.record) : {},
    handleMaterialModal,
    contractForm,
    handleApplyStorage,
    handleBatchModal,
    isNowCheckPeople,
    changeSelect,
    pagination: {
      ...pagination,
      onChange: onPageChange,
      showTotal: (total) => {
        return `共 ${total} 条`;
      },
    },
    reloadManage,
    materialToatalPrice,
    loading,
    editMaterialLoading,
    onSelectRadio,
    checkMaterialList,
    detailInfo,
    disPatchFun: (type, val) => {
      acquisitionDispatch({
        type,
        payload: val,
      });
    },
    setIsShowImportModal,
    curRes,
  });

  /** 暂存按钮  保存数据  登记 */
  const handleSave = (flag: boolean) => {
    // 对表单进行校验，获取表单数据
    contractForm.validateFields()?.then((values: any) => {
      // 如果没有选择list  提示
      if (!materielList.length) {
        return message.warning('请添加入库列表！');
      }

      // 材料入库校验列表字段  物资名称/物资分类/数量/计量单位/单价（元）
      if (values.materialType == 0) {
        let checkFlag = true,
          textMsg = '';
        materielList.forEach((item, index) => {
          // 单价
          if (!item.assetValue) {
            checkFlag = false;
            textMsg = `请完善第${index + 1}行单价后再进行提交！`;
          }
          // 计量单位
          if (!item.unitOfMeasurement) {
            checkFlag = false;
            textMsg = `请完善第${index + 1}行计量单位后再进行提交！`;
          }
          // 数量
          if (!item.quantityOrArea) {
            checkFlag = false;
            textMsg = `请完善第${index + 1}行数量后再进行提交！`;
          }
          // 物资分类
          if (!item.assetClass) {
            checkFlag = false;
            textMsg = `请完善第${index + 1}行物资分类后再进行提交！`;
          }
          // 物资名称
          if (!item.assetName) {
            checkFlag = false;
            textMsg = `请完善第${index + 1}行物资名称后再进行提交！`;
          }
          // 供应商
          if (!item.supplier) {
            checkFlag = false;
            textMsg = `请完善第${index + 1}行供应商后再进行提交！`;
          }
        });

        if (!checkFlag) {
          return message.warning(textMsg);
        }
      }

      if (values.materialType == 1) {
        // 资产入库校验数据，所有表单填写完成后 调用接口
        let checkFlag = true,
          textMsg = '';
        materielList.forEach((item, index) => {
          if (!item.formResolveFlag) {
            checkFlag = false;
            textMsg = `请完善第${index + 1}行数据后再进行提交！`;
          }
        });

        if (!checkFlag) {
          return message.warning(textMsg);
        }
      }

      // 快速定位保存
      materielList.map((item) => {
        item.ledgerAccount = '100124441000';
        if (values?.materialType == 0 && item?.supplier) {
          item.assetjson.supplier = item?.supplier;
          delete item?.supplier;
        }
        return item;
      });

      const params = {
        ...detailInfo,
        ...values,
        createTime: moment(values?.createTime).format('YYYY-MM-DD HH:mm:ss'), // 申请日期
        applyStorageId: selectApplyStorageList[0]?.id || '', // 到货验收id
        forSharing: Number(values.forSharing), // 本批物资是否共用  0否 1是
        massetMaterials: materielList, // 物料信息列表
        // createTime: moment(values?.createTime).format('YYYY-MM-DD HH:mm:ss'),
      };

      // 材料入库
      if (params.materialType == 0) {
        // 需要把是否共用赋值给list
        let sharing_flag = params?.forSharing;
        let CL_Arr = materielList?.map((item) => {
          item.sharing = sharing_flag;
          if (item?.assetjson) item.assetjson.sharing = sharing_flag;
          return item;
        });
        params.massetMaterials = CL_Arr;
      }

      setSaveFlag(flag);
      // 新增和修改接口
      if (locationProps?.state?.pageType == 'add') {
        if (contractForm.getFieldValue('id')) {
          params.id = contractForm.getFieldValue('id'); // 新增时如果导入资产/材料，则需要传id
        }
        // params.massetMaterials[0].assetClassCode = assetTypeInfo.assetClassCode ? assetTypeInfo.assetClassCode : '';
        // params.massetMaterials[0].assetType = assetTypeInfo.assetType ? assetTypeInfo.assetType : '';
        addStorageRun(params);
      } else {
        params.id = locationProps?.state?.record?.id; // 修改 id
        editStorageRun(params);
        // params.ledgerAccount = '100124441000';
      }
    });
  };

  /** 返回tab子页面 */
  const tabsItem = () => {
    let items: any[] = [
      {
        label: '申请详情',
        key: '001',
        children: (
          <>
            <div className="commonTabsBodyDom">
              <div className={Cls('tabsBodyInfoDom', `${styleFixCls}updateFormBox`)}>
                <ScrollBarLayout style={{ padding: '5px 20px' }}>
                  <DescriptionsType config={config} />
                </ScrollBarLayout>
              </div>
              <div className="tabsBodyBottomBtn">
                <Space>
                  <>
                    {((!detailInfo?.state ||
                      (detailInfo?.state == '100124561000' && !detailInfo?.checkState) ||
                      (detailInfo?.state == '100124561002' && detailInfo?.checkState == '100199021003')) &&
                      detailInfo?.createrID == getUserID()) ||
                    locationProps?.state?.pageType === 'add' ? (
                      <Button type={'primary'} onClick={() => handleSave(true)}>
                        提交
                      </Button>
                    ) : null}
                    <Button danger onClick={closeCurrent}>
                      关闭
                    </Button>
                  </>
                </Space>
              </div>
            </div>
          </>
        ),
      },
    ];
    return items;
  };

  /**
   * 关闭切换流程modal方法
   * @isDefaultModal  点击确定 true,关闭切换流程zujian,打开发起流程组件  点击取消 false 关闭切换流程组件
   */
  const closeSwitchFlowModal = (isDefaultModal: boolean) => {
    if (isDefaultModal) {
      setWorkFlowInfoObj({
        ...workFlowInfoObj,
        showWorkFlowModal: true,
      });
    } else {
      setShowSwitchFlow(false);
    }
  };

  // 导入之后设置id
  let setDetailId = (id) => {
    // 设置表单id
    contractForm?.setFieldsValue({
      ...contractForm,
      id,
    });
  };

  // 获取详情
  useEffect(() => {
    // 获取仓库列表
    // getStorageRun();
    if (locationProps?.state?.pageType != 'add') {
      getDetailRun(locationProps?.state?.record?.id);
    }
    if (locationProps?.state?.pageType == 'add') {
      acquisitionDispatch({
        type: IAcquisitionActionEnum.SELECT_TYPE,
        payload: 0,
      });
    }
    if (contractForm.getFieldValue('id')) {
      reloadManage();
    }
  }, []);

  /** 监听审核状态 */
  useEffect(() => {
    if (
      auditSuccessState &&
      detailInfo?.checkState === `${getTenantID()}${ILoadMapTypeAll.ALLFLOW_CHECKRESULT}1002` &&
      detailInfo?.state === `${getTenantID()}${ILoadMapTypeAll.ENTER_STORE_STATUS}1003`
    ) {
      approvedEnterRun({ ...detailInfo, workflowResult: true });
    }
  }, [detailInfo?.checkState, detailInfo?.state, auditSuccessState]);

  const changeRevoke = () => {
    setInvalidState({
      isShow: true,
      resObj: detailInfo,
    });
  };

  /** tabs 标签页操作 */
  const contactsTabsExtra = () => {
    return (
      <DetailInfoViewBottomBtn
        position="top"
        detailInfo={detailInfo}
        isNowCheckPeople={isNowCheckPeople}
        getDetailRun={getDetailRun}
        locationProps={locationProps}
        handleSave={handleSave}
        changeRevoke={changeRevoke}
      />
    );
  };

  /** 申请页ref */
  const { confirm } = Modal;

  const closeCurrent = () => {
    confirm({
      title: '关闭',
      icon: <QuestionCircleOutlined />,
      content: '确定要关闭当前页吗？',
      okText: '确定',
      okType: 'primary',
      cancelText: '取消',
      onOk() {
        history.push({
          pathname: locationProps?.state?.returnPathName,
          state: {
            delRouterNameSource: history.location.pathname, //必传,要删除的路由名称
            returnPathName: locationProps?.state?.returnPathName,
          },
        });
      },
      onCancel() {},
    });
  };

  return (
    <>
      <AcquisitionManageContext.Provider
        value={{
          rightTableProps: {
            dataSource: [],
            materielForm: {},
            loading: false,
            getAcquisitionTableData: ({}) => {},
            mapList: [],
            pagination: {},
            otherParams: {},
            searchList: [],
            reloadTableData: () => {},
          },
          materielList,
          curRes,
          contractForm,
          selectType,
          assetTypeInfo,
          selectFormInfo,
          selectAsssetInfo,
          selectApplyStorageList, //到货验收弹窗选择的数据集合
          acquisitionDispatch,
          handleAssetVisible, // 资产弹窗
          selectRecordId, // 资产弹窗选择的id
          pagination: {
            ...pagination,
            onChange: onPageChange,
          },
        }}
      >
        <div className={'apply-update-UpdataIntentBox'}>
          <Spin spinning={getDetailLoading || addStorageLoading || editStorageLoading || approvedEnterLoading}>
            <Row className={`${styleFixCls}row`}>
              <Col span={24} className={`${styleFixCls}row-col`}>
                <Tabs
                  className={pageStyles['commonTabs']}
                  type="card"
                  onChange={(activeKey: string) => {}}
                  items={tabsItem()}
                  destroyInactiveTabPane={true}
                  tabBarExtraContent={contactsTabsExtra()}
                />
              </Col>
            </Row>

            {/* 导入组件 */}
            {isShowBatch && (
              <UploadModal
                curRes={curRes}
                reloadManage={reloadManage}
                onClose={() => {
                  setIsShowBatch(false);
                }}
                downLoadData={downLoadData}
                isNowCheckPeople={isNowCheckPeople}
                detailInfo={detailInfo}
                modalState={{
                  applyStorageId: locationProps?.state?.pageType == 'add' ? selectApplyStorageList[0]?.id : detailInfo?.applyStorageId,
                  type: contractForm.getFieldValue('materialType').toString(),
                  storageId: locationProps?.state?.id || locationProps?.state?.record?.id,
                }}
                setDetailId={setDetailId}
              />
            )}

            {/* 选择物料列表 */}
            {openMaterialModal?.isShow && (
              <OpenMaterialModal
                isShowModal={openMaterialModal?.isShow}
                modalType={openMaterialModal?.materialType}
                applyStorageId={
                  locationProps?.state?.pageType == 'add' ? (selectApplyStorageList[0]?.id ? selectApplyStorageList[0]?.id : '') : detailInfo?.applyStorageId
                }
                onClose={() => {
                  setOpenMaterialModal({});
                }}
              />
            )}

            {/* 到货验收 */}
            {selectApplyStorage && (
              <ApplyStorageModal
                isShowModal={selectApplyStorage}
                onClickSave={(res: Record<string, any>[]) => {
                  setDetailInfo({
                    ...detailInfo,
                    applyStorageTitle: res?.[0]?.applyTitle,
                  });
                  acquisitionDispatch({
                    type: IAcquisitionActionEnum.SELECT_APPLY_STORAGE,
                    payload: [...res],
                  });
                }}
                onClose={() => {
                  setSelectApplyStorage(false);
                }}
              />
            )}

            {/* 资产 表单弹窗 */}
            {selectAssetVisible ? (
              <SelectAssetView
                onClose={() => setSelectAssetVisible(false)}
                onCloseAll={() => {
                  setSelectAssetVisible(false);
                  setOpenMaterialModal({});
                  // setOpenMaterialModal(false);
                }}
                type={formModalType}
                editMaterialRun={editMaterialRun}
                modalLoading={editMaterialLoading}
              />
            ) : null}

            {/* 工作流-----审批记录 */}
            {detailInfo?.paramObject?.[`${getTenantID()}${ILoadMapTypeAll.ALLFLOW_TYPE}1020`] && (
              <WorkflowChedkRecord
                curRes={curRes}
                dataDetailInfo={detailInfo}
                flowBusinessType={`${getTenantID()}${ILoadMapTypeAll.ALLFLOW_TYPE}1020`}
                requestController={requestController()}
                reloadPageCallback={() => {
                  getDetailRun(detailInfo?.id);
                }} // 刷新方法-详情方法
                revokeStateID={`${getTenantID()}${ILoadMapTypeAll?.ENTER_STORE_STATUS}1000`}
                allBtnFuncQuqry={workflowPowerAllBtn}
                tabPaneHeight={0.35}
                isCheckDrawer={true}
                isShowCollapse={isShowWorkRecord}
                changeCollapse={(val) => {
                  setIsShowWorkRecord(val);
                }}
                cancelStateId={`${getTenantID()}${ILoadMapTypeAll?.ENTER_STORE_STATUS}1003`}
                isSyncArchive={true}
              />
            )}
            {/* assetStorageMaterialType */}
            {/* 工作流-----发起流程审批弹窗 */}
            {workFlowInfoObj?.showWorkFlowModal && (
              <WorkflowSwitchModal
                openVisible={workFlowInfoObj?.showWorkFlowModal}
                businessInfoObj={{
                  ...workFlowInfoObj?.selectFlowRows,
                  assetStorageMaterialType: workFlowInfoObj?.selectFlowRows?.materialType, //TODO:资产暂时注释【入库-流程图bug】
                }}
                requestController={requestController()}
                orderType={workFlowInfoObj?.selectFlowRows?.orderType || orderType()}
                category={`${getTenantID()}${ILoadMapTypeAll.ALLFLOW_TYPE}1020`}
                businessCategory={`${getTenantID()}${ILoadMapTypeAll.ASSET_RK_CATEGORY}1000`}
                selectFlowID={workFlowInfoObj?.saveNoDefaultFlowID}
                reloadInfoCallback={() => {
                  // getDetailRun({ id: detailInfo?.id });
                  history.push({
                    pathname: '/assetStorage/manage',
                    state: {
                      delRouterNameSource: history.location.pathname,
                    },
                  });
                }}
                openFlowChangeModal={setShowSwitchFlow}
                onClose={() => {
                  setWorkFlowInfoObj({
                    ...workFlowInfoObj,
                    showWorkFlowModal: false,
                  });
                  history.push({
                    pathname: '/assetStorage/manage',
                    state: {
                      delRouterNameSource: history.location.pathname,
                    },
                  });
                }}
                replaceStrObj={{ own: 'own', workflowType: 'category' }}
              />
            )}

            {/* 挑选流程组件 */}
            {showSwitchFlow && (
              <WorkflowNoDefaultTable
                openVisibleSwitch={showSwitchFlow}
                onCloseSwitch={closeSwitchFlowModal}
                requestController={'assetStorage'}
                orderType={workFlowInfoObj?.selectFlowRows?.orderType || orderType()}
                category={`${getTenantID()}${ILoadMapTypeAll.ALLFLOW_TYPE}1020`}
                // businessCategory={`${getTenantID()}${ILoadMapTypeAll.ENTER_STORE_STATUS}1000`}
                businessCategory={`${getTenantID()}${ILoadMapTypeAll.ASSET_RK_CATEGORY}1000`}
                saveSelectFlowID={(flowId: string) => {
                  setWorkFlowInfoObj({
                    ...workFlowInfoObj,
                    saveNoDefaultFlowID: flowId,
                  });
                }}
                selectFlowID={workFlowInfoObj?.saveNoDefaultFlowID}
              />
            )}

            {/* 撤销弹窗 */}
            {invalidState?.isShow && (
              <RevokeModal
                resObj={invalidState?.resObj}
                revokeRequestUrl={'/assetStorage/revoke'}
                onClose={() => setInvalidState({})}
                reqBody={{ id: invalidState?.resObj?.id, state: `${getTenantID()}${ILoadMapTypeAll?.ENTER_STORE_STATUS}1000` }}
                modalTip={
                  <div style={{ color: '#000' }}>
                    确认是否撤销【<span style={{ color: 'red' }}>{invalidState?.resObj?.applyTitle}</span>】的审核, 撤销后可重新提交！
                  </div>
                }
                reloadRequest={() => {
                  history.push({
                    pathname: locationProps?.state?.returnPathName,
                    state: {
                      delRouterNameSource: history.location.pathname, //必传,要删除的路由名称
                      returnPathName: locationProps?.state?.returnPathName,
                    },
                  });
                }}
              />
            )}

            {/* 登记确认弹窗 */}
            {isShowConfirm && (
              <OneModal
                title="提示"
                open={isShowConfirm}
                onOk={() => {
                  handleSave(true);
                }}
                onCancel={() => {
                  setIsShowConfirm(false);
                }}
                children={`物资是否入库?`}
              />
            )}

            {/* 导出物资弹窗 */}
            {isShowImportModal?.isShow && <ExportModal onClose={() => setIsShowImportModal({})} reqParams={{ storageId: detailInfo?.id }} />}
          </Spin>
        </div>
      </AcquisitionManageContext.Provider>
    </>
  );
};

export default connect(({ baseLogin, navTab }: Record<string, any>) => ({
  curRes: baseLogin?.permissions,
  navTab,
}))(AcceptUpdateView);
